/**
 * FyLLGen - A Java based tool for collecting and distributing family data
 *
 * Copyright (C) 2007-2011 Christian Packenius
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
package de.chris_soft.fyllgen.widget.dialog;

import java.util.List;

import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.events.ShellEvent;
import org.eclipse.swt.events.ShellListener;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Dialog;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;

import de.chris_soft.fyllgen.GUI;
import de.chris_soft.fyllgen.data.Person;
import de.chris_soft.fyllgen.utilities.SwtUtilities;

/**
 * Wahl des Reports und der Export selbst.
 * @author Christian Packenius, 20110930.
 */
public class ReportChoiceDialog extends Dialog implements ShellListener, SelectionListener {
  /**
   * Dialog window.
   */
  private final Shell shell;

  /**
   * Liste zu exportierender Personen.
   */
  private final List<Person> persons;

  /**
   * Constructor.
   * @param parent The parent shell for this dialog.
   * @param persons
   */
  public ReportChoiceDialog(Shell parent, List<Person> persons) {
    super(parent, 0);
    this.persons = persons;

    // Fenster administrieren.
    shell = new Shell(parent, SWT.CLOSE | SWT.TITLE | SWT.APPLICATION_MODAL);
    shell.setImage(GUI.instance.shellIcon);
    shell.addShellListener(this);
    shell.setText("Export-Typ");
    shell.setSize(400, 200);
    shell.setLayout(new GridLayout(1, false));

    int blase;

    // Noch mittig ins vorhandene Fenster setzen.
    SwtUtilities.centerInParent(shell, parent);
  }

  /**
   * Open this dialog.
   */
  public void open() {
    shell.open();

    // Ereignis-Liste abarbeiten.
    eventQueue();
  }

  /**
   * SWT event queue.
   */
  private void eventQueue() {
    Display display = Display.getDefault();
    while (!shell.isDisposed()) {
      if (!display.readAndDispatch()) {
        display.sleep();
      }
    }
  }

  /**
   * @see org.eclipse.swt.events.ShellListener#shellActivated(org.eclipse.swt.events.ShellEvent)
   */
  public void shellActivated(ShellEvent e) {
    // Ignorieren.
  }

  /**
   * @see org.eclipse.swt.events.ShellListener#shellClosed(org.eclipse.swt.events.ShellEvent)
   */
  public void shellClosed(ShellEvent e) {
    // Ignorieren.
  }

  /**
   * @see org.eclipse.swt.events.ShellListener#shellDeactivated(org.eclipse.swt.events.ShellEvent)
   */
  public void shellDeactivated(ShellEvent e) {
    // Ignorieren.
  }

  /**
   * @see org.eclipse.swt.events.ShellListener#shellDeiconified(org.eclipse.swt.events.ShellEvent)
   */
  public void shellDeiconified(ShellEvent e) {
    // Ignorieren.
  }

  /**
   * @see org.eclipse.swt.events.ShellListener#shellIconified(org.eclipse.swt.events.ShellEvent)
   */
  public void shellIconified(ShellEvent e) {
    // Ignorieren.
  }

  /**
   * @see org.eclipse.swt.events.SelectionListener#widgetDefaultSelected(org.eclipse.swt.events.SelectionEvent)
   */
  public void widgetDefaultSelected(SelectionEvent e) {
    widgetSelected(e);
  }

  /**
   * @see org.eclipse.swt.events.SelectionListener#widgetSelected(org.eclipse.swt.events.SelectionEvent)
   */
  public void widgetSelected(SelectionEvent e) {
  }
}
